package org.smartagents.body;

import org.smartagents.enviro.EnvironmentConstants;

public class BodyFactory {

    public static Body buildBody(String bodydetails, int x, int y) {

        //details - substance1&substance2

        Body body = new Body();

        body.setX(x);
        body.setY(y);

        String[] bodybrain = bodydetails.split(EnvironmentConstants.BODY_BRAIN_SEPARATOR);

        String[] substances = bodybrain[0].split(EnvironmentConstants.SUBSTANCE_SEPARATOR);
        Substance substance;
        for (String sub: substances) {
            substance = SubstanceFactory.getSubstance(sub);
            substance.setEnclosing(body);
            body.getSubstances().add(substance);
        }

        Neurone cortex = BrainBuilder.brainFromString(bodybrain[1]);
        body.setCortex(cortex);

        

        return body;
    }

}
